/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bash.jcouture.util.swing;

import com.bash.compta.data.CategorieDepense;
import com.bash.compta.data.Depense;
import com.bash.compta.db4o.MagicData;

import java.util.List;
import java.util.Locale;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author bashizip
 */
public class TotalGeneralTM extends AbstractTableModel {

    private List<CategorieDepense> cdep = MagicData.getAllObjects(CategorieDepense.class);
    private String[] colones = {"", "", ""};
    double totalUSD = 0,
            totalCDF = 0;

    public TotalGeneralTM() {

        for (CategorieDepense d : cdep) {

            totalUSD += MagicData.getTotalUSDOfDepenseType(d.getLibele());
             totalCDF += MagicData.getTotalCDFOfDepenseType(d.getLibele());

        }     
    }

   

    public int getRowCount() {
        return 1;
    }

    public int getColumnCount() {
        return colones.length;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {

        Object toReturn = null;

        switch (columnIndex) {
            case 0:
                toReturn = "TOTAL";
                break;
            case 1:
                toReturn = MyStringUtils.toCurrencyFormat(totalUSD, Locale.US);;
                break;
            case 2:

               toReturn = MyStringUtils.toCustomCurrencyFormat(totalCDF);
                break;
            

        }
        return toReturn;

    }

    @Override
    public String getColumnName(int column) {
        return colones[column];
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
    }
}
